use czsc_rs::{welcome, generate_klines, generate_strategy_returns, CzscTrader, CzscStrategyBase, Position, CzscJsonStrategy};

use std::collections::HashMap;
use chrono::Utc;

use czsc_rs::objects::{NewBar, Direction};
use czsc_rs::signals::tas::*;

fn main() {
    println!("CZSC Rust 技术分析信号测试");
    
    // 创建测试数据
    let mut bars = Vec::new();
    let base_time = Utc::now();
    
    // 创建一些模拟的K线数据
    for i in 0..100 {
        let dt = base_time + chrono::Duration::minutes(i as i64);
        let bar = NewBar::new(
            "000001.SZ".to_string(),
            i as i32,
            dt,
            czsc_rs::objects::enums::Freq::Min1,
            10.0 + (i as f64 * 0.1),
            10.0 + (i as f64 * 0.1) + (i % 3 - 1) as f64 * 0.2,
            10.5 + (i as f64 * 0.1),
            9.5 + (i as f64 * 0.1),
            1000000.0,
            10000000.0,
        );
        bars.push(bar);
    }
    
    // 测试MACD基础信号
    let mut kwargs = HashMap::new();
    kwargs.insert("fastperiod".to_string(), 12.0);
    kwargs.insert("slowperiod".to_string(), 26.0);
    kwargs.insert("signalperiod".to_string(), 9.0);
    
    let macd_signals = tas_macd_base_v221028(&bars, &kwargs);
    println!("MACD基础信号数量: {}", macd_signals.len());
    for (name, signal) in &macd_signals {
        println!("  {}: {} -> {:?}", name, signal.value, signal.direction);
    }
    
    // 测试均线基础信号
    kwargs.clear();
    kwargs.insert("timeperiod".to_string(), 20.0);
    
    let ma_signals = tas_ma_base_v221101(&bars, &kwargs);
    println!("均线基础信号数量: {}", ma_signals.len());
    for (name, signal) in &ma_signals {
        println!("  {}: {} -> {:?}", name, signal.value, signal.direction);
    }
    
    // 测试RSI基础信号
    kwargs.clear();
    kwargs.insert("timeperiod".to_string(), 14.0);
    kwargs.insert("overbought".to_string(), 70.0);
    kwargs.insert("oversold".to_string(), 30.0);
    
    let rsi_signals = tas_rsi_base_v230227(&bars, &kwargs);
    println!("RSI基础信号数量: {}", rsi_signals.len());
    for (name, signal) in &rsi_signals {
        println!("  {}: {} -> {:?}", name, signal.value, signal.direction);
    }
    
    println!("测试完成！");
} 